package com.car.web.controller.index;

import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import javax.annotation.Resource;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.FileUploadException;
import org.apache.commons.fileupload.disk.DiskFileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
import org.apache.log4j.Logger;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.multipart.commons.CommonsMultipartFile;
import org.springframework.web.servlet.ModelAndView;

import com.car.dal.dao.client.TgClientDao;
import com.car.dal.dao.client.TgClientImpDao;
import com.car.dal.dao.department.TgDepartmentDao;
import com.car.dal.dao.reception.TgReceptionDao;
import com.car.dal.dao.source.TgSourceDao;
import com.car.dal.dao.sudent.StudentDao;
import com.car.dal.dao.sudent.StudentDaoImpl;
import com.car.dal.dao.user.UserDao;
import com.car.dal.dao.user.UserinfoDao;
import com.car.dal.dao.usergroup.TgUsergroupDao;
import com.car.dal.dao.vote.JsVoteDao;
import com.car.dal.object.JsVote;
import com.car.dal.object.TgClient;
import com.car.dal.object.TgClientImp;
import com.car.dal.object.TgSource;
import com.car.dal.object.TgStudent;
import com.car.dal.object.TgUser;
import com.car.dal.object.TgUserinfo;
import com.car.util.DateUtil;
import com.car.util.ExcelUtil;
import com.car.util.JsonExecutor;
import com.car.util.JsonExecutor.JsonBiz;
import com.car.util.Constants;
import com.car.util.MathUtil;
import com.car.util.Page;
import com.car.util.PageUtil;
import com.car.util.ReadExcel;
import com.car.util.Result;
import com.car.util.ResultSupport;
import com.car.util.StringUtil;
import com.car.util.UserUtil;
import com.car.util.WebExecutor;
import com.car.util.WebExecutor.Biz;
import com.car.util.upload_download_for_ftp.Ftp;
import com.car.util.upload_download_for_ftp.SFTPUtil;
import com.car.util.WriterExcel;
import com.car.web.controller.base.BaseController;
import com.car.web.controller.base.BaseVo;
import com.ssi.utils.SsiUtils;

/**
 * 登录控制
 * 
 * @author Administrator
 * 
 */
@Controller
@RequestMapping("/consu")
public class ConsuControllerZh extends BaseController {

	private static final Logger logger = Logger
			.getLogger(ConsuControllerZh.class);
	@Resource
	private UserDao userDao;
	@Resource
	private TgUsergroupDao tgUsergroupDao;
	@Resource
	private TgDepartmentDao tgDepartmentDao;
	@Resource
	private UserinfoDao userinfoDao;
	@Resource
	private TgClientImpDao clientImpDao;
	@Resource
	private JsVoteDao jsVoteDao;
	@Resource
	private TgSourceDao sourceDao;
    @Resource
    private TgClientDao clientDao;
    @Resource
    private StudentDao studentDao;
    @Resource
    private TgReceptionDao receptionDao;

    //格式化日期
    SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmssSSS");
    

	// 进入客戶資源添加
	@RequestMapping(value = "/consultant_import_add")
	public ModelAndView consultant_import_add(ModelMap modelMap,
			final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, loginVo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String type = request.getParameter("type");
				JsVote clientImp = new JsVote();
				if(id!=null && !"".equals(id)){
					clientImp = jsVoteDao.findById(JsVote.class, Long.valueOf(id));
				}
				TgUser u = UserUtil.getUserFromCookies();
				TgUserinfo user  = new TgUserinfo();
				user.setLocked(0);
   				user.setJob(u.getJob());
   				List<TgUserinfo> uList =userinfoDao.getUserInfoByUserInfo(user);
   				if(u.getJob().equals("网络推广专员")){
   					user.setJob("网络推广主管");
   					userinfoDao.getUserInfoByUserInfo(user);
   					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
   				}else if(u.getJob().equals("市场专员")){
   					user.setJob("市场主管");
   					userinfoDao.getUserInfoByUserInfo(user);
   					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
   					user.setJob("市场副主管");
   					userinfoDao.getUserInfoByUserInfo(user);
   					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
   				}else if(u.getJob().equals("网络推广主管")){
   					user.setJob("网络推广专员");
   					userinfoDao.getUserInfoByUserInfo(user);
   					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
   				}else if(u.getJob().equals("市场主管") || u.getJob().equals("市场副主管")){
   					user.setJob("市场专员");
   					userinfoDao.getUserInfoByUserInfo(user);
   					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
   				}
				List<TgSource> souList = sourceDao.getAll();
				result.setDefaultModel("uList", uList);
				result.setDefaultModel("souList", souList);
				result.setDefaultModel("clientImp", clientImp);
				result.setDefaultModel("type", type);
				return result;
			}
		});
		return new ModelAndView("consultant/consultant_import_add", modelMap);
	}
	// 进入客戶資源添加
	@RequestMapping(value = "/consultant_importclient_add")
	public ModelAndView consultant_importclient_add(ModelMap modelMap,
			final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, loginVo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String type = request.getParameter("type");
				TgClient clientImp = new TgClient();
				if(id!=null && !"".equals(id)){
					clientImp = clientDao.findById(TgClient.class, Long.valueOf(id));
				}
				JsVote vote = new JsVote();
				vote.setKeyname(clientImp.getKeyname());
				List<JsVote> voteList= jsVoteDao.findByExample(vote);
				if(null!=voteList&&voteList.size()>0) {
					result.setDefaultModel("vote", voteList.get(0));
				}
				TgUser u = UserUtil.getUserFromCookies();
				TgUserinfo user  = new TgUserinfo();
				user.setLocked(0);
				user.setJob(u.getJob());
				List<TgUserinfo> uList =userinfoDao.getUserInfoByUserInfo(user);
				if(u.getJob().equals("网络推广专员")){
					user.setJob("网络推广主管");
					userinfoDao.getUserInfoByUserInfo(user);
					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
				}else if(u.getJob().equals("市场专员")){
					user.setJob("市场主管");
					userinfoDao.getUserInfoByUserInfo(user);
					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
					user.setJob("市场副主管");
					userinfoDao.getUserInfoByUserInfo(user);
					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
				}else if(u.getJob().equals("网络推广主管")){
					user.setJob("网络推广专员");
					userinfoDao.getUserInfoByUserInfo(user);
					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
				}else if(u.getJob().equals("市场主管") || u.getJob().equals("市场副主管")){
					user.setJob("市场专员");
					userinfoDao.getUserInfoByUserInfo(user);
					uList.addAll(userinfoDao.getUserInfoByUserInfo(user));
				}
				List<TgSource> souList = sourceDao.getAll();
				result.setDefaultModel("uList", uList);
				result.setDefaultModel("souList", souList);
				result.setDefaultModel("clientImp", clientImp);
				result.setDefaultModel("type", type);
				return result;
			}
		});
		return new ModelAndView("consultant/consultant_importclient_add", modelMap);
	}
	
	//异步查询渠道来源
	@RequestMapping(value = "/getSourceByname")
	public ModelAndView getSourceByname(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String name = request.getParameter("name");
				TgSource source = new TgSource();
				source.setName(name);
				List<TgSource> souList = sourceDao.findBySouName(source);
				if (souList != null && souList.size() > 0) {
                    result.setDefaultModel("source1", souList.get(0));
                }
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	
	
	// 异步添加客户资源
	@RequestMapping(value = "/consultant_importClient_add_go")
	public ModelAndView consultant_importClient_add_go(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String lianxi_name = request.getParameter("lianxi_name");
				String tui_username = request.getParameter("tui_username");
				String type = request.getParameter("type");
				String fwly = request.getParameter("fwly");
				String cs_url = request.getParameter("cs_url");
				String keyword = request.getParameter("keyword");
				String province = request.getParameter("province");
				String city = request.getParameter("city");
				String address = request.getParameter("address");
				String phone = request.getParameter("phone");
				String weixin = request.getParameter("weixin");
				String qq = request.getParameter("qq");
				String age = request.getParameter("age");
				String student_msg = request.getParameter("studentMsg");
				String descs = request.getParameter("descs");
				String jl_time = request.getParameter("jl_time");
				String keyname = request.getParameter("keyname");
				
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				TgUser user = UserUtil.getUserFromCookies();
				if (user == null) {
					return result;
				}
				TgClient client=new TgClient();
				JsVote vote = new JsVote();

				client.setNickname(lianxi_name);
				client.setSource(type);
				client.setProvince(province);
				client.setCity(city);
				client.setAddress(address);
				client.setWeixin(weixin);
				client.setQq(qq);
				client.setDescs(descs);
				
				vote.setUsername(user.getUsername());
				vote.setLianxi_name(lianxi_name);
				vote.setTui_username(tui_username);
				vote.setType(type);
				vote.setFwly(fwly);
				vote.setCs_url(cs_url);
				vote.setKeyword(keyword);
				vote.setProvince(province);
				vote.setProvince_city(city);
				vote.setCity(city);
				vote.setAddress(address);
				vote.setWeixin(weixin);
				vote.setQq(qq);
				vote.setAge(age);
				vote.setStudent_msg(student_msg);
				if(id!=null && !"".equals(id)){
					client.setId(Long.valueOf(id));
					clientDao.update(client);
				}else{
					TgClient clientImp2 = new TgClient();
					clientImp2.setPhone(phone);
					clientImp2.setSourceTable(1);
					Long count = clientDao.countEqual(clientImp2);
					if(count>0){
						vote.setColor("1");
					}
					
					clientImp2.setKeyname(SsiUtils.randomUUID());
					
					clientImp2.setCdate(new Date().getTime()/1000);
					clientImp2.setSourceTable(1);
					clientDao.insert(clientImp2);
				}
				if(keyname!=null && !"".equals(keyname)) {
					try {
						if(jl_time!=null && !jl_time.equals("")){
							vote.setJl_time(sdf2.parse(jl_time));
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					JsVote jsVote=new JsVote();
					jsVote.setKeyname(keyname);
					List<JsVote> voteList=jsVoteDao.findByExample(jsVote);
					if(null!=voteList&&voteList.size()>0) {
						vote.setId(voteList.get(0).getId());
						jsVoteDao.update(vote);
						result.setDefaultModel("msg", "1");
					}
				}else {
					JsVote clientImp2 = new JsVote();
					clientImp2.setPhone(phone);
					clientImp2.setSourceTable(1);
					Long count = jsVoteDao.countEqual(clientImp2);
					if(count>0){
						vote.setColor("1");
					}
					
					try {
						if(jl_time!=null && !jl_time.equals("")){
							vote.setJl_time(sdf.parse(jl_time));
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					vote.setKeyname(SsiUtils.randomUUID());
					
					vote.setCdate(new Date().getTime()/1000);
					vote.setSourceTable(1);
					jsVoteDao.insert(vote);
					result.setDefaultModel("msg", "1");
					
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	// 异步添加客户资源
	@RequestMapping(value = "/consultant_import_add_go")
	public ModelAndView consultant_import_add_go(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String lianxi_name = request.getParameter("lianxi_name");
				String tui_username = request.getParameter("tui_username");
				String type = request.getParameter("type");
				String fwly = request.getParameter("fwly");
				String cs_url = request.getParameter("cs_url");
				
				String keyword = request.getParameter("keyword");
				String province = request.getParameter("province");
				String city = request.getParameter("city");
				String address = request.getParameter("address");
				String phone = request.getParameter("phone");
				String weixin = request.getParameter("weixin");
				String qq = request.getParameter("qq");
				String age = request.getParameter("age");
				String student_msg = request.getParameter("studentMsg");
				String descs = request.getParameter("descs");
				String jl_time = request.getParameter("jl_time");
				
				SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
				SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
				TgUser user = UserUtil.getUserFromCookies();
				if (user == null) {
					return result;
				}
				
				JsVote clientImp = new JsVote();
				
				List<JsVote> votelist = null;
				int ask_cn = 0;
				if(phone!=null && phone!=""){
					clientImp.setPhone(phone);
					votelist = jsVoteDao.findByExample(clientImp);
					if(votelist!=null && votelist.size()>0){
						ask_cn = votelist.size();
					}
				}
				clientImp.setAsk_cn(ask_cn);
				clientImp.setUsername(user.getUsername());
				clientImp.setLianxi_name(lianxi_name);
				clientImp.setTui_username(tui_username);
				clientImp.setType(type);
				clientImp.setFwly(fwly);
				clientImp.setCs_url(cs_url);
				clientImp.setKeyword(keyword);
				clientImp.setProvince(province);
				clientImp.setProvince_city(city);
				clientImp.setCity(province+" "+city);
				clientImp.setAddress(address);
				clientImp.setWeixin(weixin);
				clientImp.setQq(qq);
				clientImp.setAge(age);
				
				clientImp.setStudent_msg(student_msg);
				clientImp.setDescs(descs);
				if(id!=null && !"".equals(id)){
					try {
						if(jl_time!=null && !jl_time.equals("")){
							clientImp.setJl_time(sdf2.parse(jl_time));
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					clientImp.setId(Long.valueOf(id));
					jsVoteDao.update(clientImp);
					result.setDefaultModel("msg", "1");
				}else{
					JsVote clientImp2 = new JsVote();
					clientImp2.setPhone(phone);
					clientImp2.setSourceTable(1);
					Long count = jsVoteDao.countEqual(clientImp2);
					if(count>0){
						clientImp.setColor("1");
					}
					
					try {
						if(jl_time!=null && !jl_time.equals("")){
							clientImp.setJl_time(sdf.parse(jl_time));
						}
					} catch (ParseException e) {
						e.printStackTrace();
					}
					clientImp.setKeyname(SsiUtils.randomUUID());
					
					clientImp.setCdate(new Date().getTime()/1000);
					clientImp.setSourceTable(1);
					jsVoteDao.insert(clientImp);
					result.setDefaultModel("msg", "1");
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	//删除客户资源
	@RequestMapping(value = "/consultant_delete")
	public ModelAndView consultant_delete(ModelMap modelMap,
			final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, loginVo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String ids = request.getParameter("ids");
				TgUser user = UserUtil.getUserFromCookies();

				JsVote clientImp;
				if(ids!=null && !ids.equals("")){
					String[] id = ids.split(",");
					if(id!=null && id.length>0){
						for(int i=0;i<id.length;i++){
							clientImp = jsVoteDao.findById(JsVote.class, Long.valueOf(id[i]));
							if(clientImp!=null && clientImp.getState().equals("0")){
								if(clientImp.getUsername().equals(user.getUsername())){
									jsVoteDao.delete(JsVote.class, Long.valueOf(id[i]));
									result.setDefaultModel("msg", "1");
								}else{
									result.setDefaultModel("msg", "0");
								}
							}else{
								result.setDefaultModel("msg", "2");
							}
						}
					}
				}
				return result;
			}
		});

		return new ModelAndView("", modelMap);
	}
	
	//标记无效
	@RequestMapping(value = "/consultant_update")
	public ModelAndView consultant_update(ModelMap modelMap,
			final LoginVo loginVo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, loginVo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String ids = request.getParameter("ids");
				TgUser user = UserUtil.getUserFromCookies();
				
				JsVote clientImp = new JsVote();
				if(ids!=null && !ids.equals("")){
					if(user.getUsername().equals("admin")){
						String[] id = ids.split(",");
						if(id!=null && id.length>0){
							for(int i=0;i<id.length;i++){
								clientImp.setId(Long.valueOf(id[i]));
								clientImp.setSt_type(2);
								jsVoteDao.update(clientImp);
								result.setDefaultModel("msg", "1");
							}
						}
					}else{
						String[] id = ids.split(",");
						if(id!=null && id.length>0){
							for(int i=0;i<id.length;i++){
								clientImp = jsVoteDao.findById(JsVote.class, Long.valueOf(id[i]));
								if(clientImp!=null && clientImp.getState().equals("0")){
									if(clientImp.getColor()!=null && clientImp.getColor().equals("1")){
										if(clientImp.getUsername().equals(user.getUsername())){
											clientImpDao.delete(TgClientImp.class, Long.valueOf(id[i]));
											result.setDefaultModel("msg", "1");
										}else{
											result.setDefaultModel("msg", "0");
										}
									}else{
										if(clientImp.getUsername().equals(user.getUsername())){
											clientImp.setId(Long.valueOf(id[i]));
											clientImp.setSt_type(2);
											jsVoteDao.update(clientImp);
											result.setDefaultModel("msg", "1");
										}else{
											result.setDefaultModel("msg", "0");
										}
									}
								}else{
									result.setDefaultModel("msg", "2");
								}
								
							}
						}
					}
				}
				return result;
			}
		});

		return new ModelAndView("", modelMap);
	}
	
	/**
	 * @Description:资源导入页面
	 * @author: Hqd
	 * @date: 2017年11月27日 下午3:04:07 
	 * @return
	 */
	@RequestMapping(value = "/consultant_import")
	public ModelAndView consultant_import(HttpServletRequest request,String flag,String type) {
		ModelAndView mav=new ModelAndView("consultant/consultant_import");
		if(flag != null){
			mav.addObject("flag", flag);
			mav.addObject("type", type);
		}
		return mav;
	}
	/**
	 * @Description:确定导入
	 * @author: Hqd
	 * @date: 2017年11月27日 下午2:17:13 
	 * @return
	 */
	@RequestMapping(value = "/consultant_import_go_jsp")
	public ModelAndView consultant_import_go_jsp(ModelMap modelMap,@RequestParam("file") final MultipartFile file,
			final HttpServletRequest request) throws Exception {
		String flag = "true";
		String lx = "";
		try{
			//获取页面的传入文件
			CommonsMultipartFile cf= (CommonsMultipartFile)file;  
			DiskFileItem fi = (DiskFileItem)cf.getFileItem();  
			//文件输出流（cvs）
	        InputStream inputStream = fi.getInputStream();
	        
			File files = fi.getStoreLocation(); 
			
			//System.out.println(files.getName());
			//System.out.println(cf.getOriginalFilename());
			String fileName = cf.getOriginalFilename();
			
			String type = request.getParameter("type");
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm");
			SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
			SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
			SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
			SimpleDateFormat sdf5 = new SimpleDateFormat("yyyyMMdd");
			
			TgUser user = UserUtil.getUserFromCookies();
			if (user == null) {
				flag = "false";
			}
			//不执行下面的
			JsVote client_imp = null;
			List<String> dataList = new ArrayList<String>();
			Integer total=0;
				//url = url.replaceAll("//", "/");
				if (type.equals("k4jmt5lbp8ne")) {//400电话
					dataList = new ArrayList<String>();
					List<?> list = ExcelUtil.readExcel(files);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							dataList.add(content);
						}
					}
					if (dataList != null && dataList.size() > 0) {
						JsVote clientImp2 = new JsVote();
						TgClient client = new TgClient();
						for (int i = 1; i < dataList.size(); i++) {
							if (dataList.get(i) != null
									&& !"".equals(dataList.get(i))) {
								String[] data = dataList.get(i)
										.split(",");
								if (data != null && data.length > 0) {
									client_imp = new JsVote();
									client_imp.setUsername(user.getUsername());
									client_imp.setTui_username(user.getUsername());
									client_imp.setType(type);
									for (int j = 0; j < data.length; j++) {
										if (j == 0) {
											client_imp.setLianxi_name(data[j]);
										} else if (j == 1) {
											client_imp.setPhone(data[j].replace(".00", ""));
											clientImp2.setPhone(data[j].replace(".00", ""));
											clientImp2.setSourceTable(1);
											Long count = jsVoteDao.countEqual(clientImp2);
											if(count>0){
												client_imp.setColor("1");
											}
											client.setPhone(data[j].replace(".00", ""));
											Integer count2 = clientDao.getClientCount(client);
											if(count2>0){
												client_imp.setColor("1");
											}
										} else if (j == 2) {
											client_imp.setCity(data[j]);
										} else if (j == 3) {
											client_imp.setJl_time(sdf4.parse(data[j]));
										} else if (j == 4) {
											client_imp.setStudent_msg(data[j]);
										} 
									}
									client_imp.setKeyname(SsiUtils.randomUUID());
									client_imp.setCdate(new Date().getTime()/1000);
									client_imp.setSourceTable(1);
									jsVoteDao.insert(client_imp);
									total++;
								}
							}
						}
					}
				} else if (type.equals("baiduxunke")) {// 百度寻客
					dataList = ReadExcel.importCsv(inputStream);
					if (dataList != null && dataList.size() > 0) {
						JsVote clientImp2 = new JsVote();
						for (int i = 1; i < dataList.size(); i++) {
							if (dataList.get(i) != null
									&& !"".equals(dataList.get(i))) {
								String[] data = dataList.get(i).split(
										",");
								if (data != null && data.length > 0) {
									client_imp = new JsVote();
									client_imp.setUsername(user.getUsername());
									client_imp.setTui_username(user.getUsername());
									client_imp.setType(type);
									for (int j = 0; j < data.length; j++) {
										if (j == 0) {
											client_imp.setJl_time(sdf1.parse(data[j].trim()));
										} else if (j == 1) {
											if(data[j]!=null && !"".equals(data[j])){
												client_imp.setPhone(data[j].replace(".00", ""));
												clientImp2.setPhone(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}
											}
										} else if (j == 2) {
											client_imp.setLianxi_name(data[j]);
										} else if (j == 4) {
											client_imp.setCity(data[j]);
										} else if (j == 5) {
											client_imp.setKeyword(data[j]);
										}
									}
									client_imp.setKeyname(SsiUtils.randomUUID());
									client_imp.setCdate(new Date().getTime()/1000);
									client_imp.setSourceTable(1);
									jsVoteDao.insert(client_imp);
									total++;
								}
							}
						}
					}
				}
				else if (type.equals("frvmppoifgmb")) {// 今日头条
					try {
						dataList = new ArrayList<String>();
						dataList = ReadExcel.importCsv(inputStream);
						if (dataList != null && dataList.size() > 0) {
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										
										for (int j = 0; j < data.length; j++) {
											if (j == 1) {
												client_imp.setGg_id(data[j]+"");
											} else if (j == 2) {
												client_imp.setLianxi_name(data[j]);
											} else if (j == 3) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} else if (j == 4) {
												client_imp.setAge(data[j]);
											} else if (j == 5) {
												client_imp.setCity(data[j]);
											} else if (j == 6) {
												String[] dax = data[j].split(":");
												if(dax!=null && dax.length==2){
													try {
														client_imp.setJl_time(sdf4.parse(data[j].trim()+":00"));
													} catch (ParseException e) {
														client_imp.setJl_time(sdf1.parse(data[j].trim()+":00"));
														}
												}else{
													try {
														client_imp.setJl_time(sdf4.parse(data[j].trim()));
													} catch (ParseException e) {
														client_imp.setJl_time(sdf1.parse(data[j].trim()));
													}
													
												}
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							} 
						} 
					} catch (Exception e) {
						e.printStackTrace();
					} 
				} else if (type.equals("lixianbao")) {// 离线宝
					try {
						dataList = new ArrayList<String>();
						List<?> list = ExcelUtil.readExcel(files,fileName);
						for (int i = 0; i < list.size(); i++) {
							List<?> one = (List<?>) list.get(i);
							if (one != null && one.size() > 0) {
								String content = "";
								for (int j = 0; j < one.size(); j++) {
									if (j == one.size() - 1) {
										content += one.get(j);
									} else {
										content += one.get(j) + ",";
									}
								}
								dataList.add(content);
							}
						}
						if (dataList != null && dataList.size() > 0) {
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											/*if (j == 0) {
												client_imp.setPhoneType(data[j]);
											} else if (j == 1) {
												client_imp.setMeitily(data[j]);
											} else if (j == 2) {
												client_imp.setJihua(data[j]);
											} else if (j == 3) {
												client_imp.setDanyuan(data[j]);
											} else if (j == 4) {
												client_imp.setFenjihao(data[j]);
											} else */if (j == 5) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} /*else if (j == 6) {
												client_imp.setBj_phone(data[j]);
											} else*/ if (j == 7) {
												client_imp.setCity(data[7]);
											} else if (j == 8) {
												client_imp.setCity(data[7]+ " "+ data[8]);
											} else if (j == 9) {
												client_imp.setJl_time(sdf4.parse(data[j].trim()));
											} /*else if (j == 10) {
												client_imp.setTh_end(data[j]);
												client_imp.setJl_time(sdf4.parse(data[j].trim()));
											} else if (j == 11) {
												client_imp.setTh_timeL(data[j]);
											} else if (j == 12) {
												client_imp.setTh_money(data[j]);
											} else if (j == 13) {
												client_imp.setTh_state(data[j]);
											} else if (j == 14) {
												client_imp.setTh_dengdai(data[j]);
											}*/ else if (j == 15) {
												client_imp.setIp(data[j]);
											} /*else if (j == 16) {
												client_imp.setIp_city(data[16]+ " "+ data[17]);
											} else if (j == 18) {
												client_imp.setSb_type(data[j]);
											} else if (j == 19) {
												client_imp.setShebei(data[j]);
											} else if (j == 20) {
												client_imp.setSb_xitong(data[j]);
											} else if (j == 21) {
												client_imp.setSite(data[j]);
											} else if (j == 22) {
												client_imp.setTj_url(data[j]);
											}*/
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						}
					} catch (IOException e) {
						e.printStackTrace();
					}
				} else if (type.equals("shangqiaogt")) {// 商桥沟通客户
					dataList = WriterExcel.readExcel(files);
					if (dataList != null && dataList.size() > 0) {
						JsVote clientImp2 = new JsVote();
						for (int i = 4; i < dataList.size(); i++) {
							if (dataList.get(i) != null
									&& !"".equals(dataList.get(i))) {
								String[] data = dataList.get(i).split(
										",");
								if (data != null && data.length > 0) {
									client_imp = new JsVote();
									client_imp.setUsername(user.getUsername());
									client_imp.setTui_username(user.getUsername());
									client_imp.setType(type);
									
									JsVote clientImp3 = new JsVote();
									for (int j = 0; j < data.length; j++) {
										/*if (j == 1) {
											client_imp.setFw_start(data[j]);
										} else if (j == 2) {
											client_imp.setTh_start(data[j]);
											client_imp.setJl_time(sdf3.parse(data[j].trim()));
										} else*/
										if (j == 3) {
											client_imp.setLianxi_name(data[j]);
										} else if (j == 4) {
											if(data[j]!=null && !"".equals(data[j])){
												client_imp.setPhone(data[j].replace(".00", ""));
												clientImp2.setPhone(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}
											}
										} else if (j == 5) {
											if(data[j]!=null && !"".equals(data[j])){
												client_imp.setQq(data[j].replace(".00", ""));
												clientImp3.setQq(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}
											}
										} else if (j == 6) {
											client_imp.setFwly(data[j]);
										} else if (j == 7) {
											client_imp.setCs_url(data[j]);
										} else if (j == 8) {
											client_imp.setKeyword(data[j]);
										} /*else if (j == 9) {
											client_imp.setSs_keyword(data[j]);
										}*/
									}
									client_imp.setKeyname(SsiUtils.randomUUID());
									client_imp.setCdate(new Date().getTime()/1000);
									client_imp.setSourceTable(1);
									jsVoteDao.insert(client_imp);
									total++;
								}
							}
						}
					}
				} else if (type.equals("edhhjon7t6za")) {// 商桥留言
					dataList = ReadExcel.importCsv(inputStream);
					if (dataList != null && dataList.size() > 0) {
						client_imp = new JsVote();
						client_imp.setUsername(user.getUsername());
						client_imp.setTui_username(user.getUsername());
						client_imp.setType(type);
						JsVote clientImp2 = new JsVote();
						for (int i = 1; i < dataList.size(); i++) {
							String[] data = dataList.get(i).split(",");
							for(int j=0;j<data.length;j++){
								if(j==0){
									client_imp.setJl_time(sdf4.parse(data[j].trim()));
								}else if(j==1){
									client_imp.setCity(data[j]);
								}else if(j==2){
									client_imp.setFwly(data[j]);
								}else if(j==3){
									client_imp.setKeyword(data[j]);
								}
								/*else if(j==4){
									client_imp.setSite(data[j]);
								}else if(j==5){
									client_imp.setTj_url(data[j]);
								}*/else if(j==6){
									client_imp.setLianxi_name(data[j]);
								}else if(j==7){
									if(data[j]!=null && !"".equals(data[j])){
										client_imp.setPhone(data[j].replace(".00", ""));
										clientImp2.setPhone(data[j].replace(".00", ""));
										clientImp2.setSourceTable(1);
										Long count = jsVoteDao.countEqual(clientImp2);
										if(count>0){
											client_imp.setColor("1");
										}
									}
								}else if(j==8){
									client_imp.setAddress(data[j]);
								}else if(j==9){
									client_imp.setEmail(data[j]);
								}/*else if(j==10){
									client_imp.setMsg(data[j]);
								}else if(j==11){
									client_imp.setBeizhu(data[j]);
								}else if(j==12){
									client_imp.setGt_state(data[j]);
								}*/
							}
							client_imp.setCdate(new Date().getTime()/1000);
							client_imp.setSourceTable(1);
							jsVoteDao.insert(client_imp);
							total++;
						}
						
					}
				} else if (type.equals("yunxiaoke")) {// 云销客
					dataList = new ArrayList<String>();
					List<?> list = ExcelUtil.readExcel(files,fileName);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							dataList.add(content);
						}
					}
					if (dataList != null && dataList.size() > 0) {
						String content = dataList.get(0);
						if (content.indexOf("手机型号") > 1) {
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf4.parse("2017-"+data[j].trim()));
											} /*else if (j == 1) {
												client_imp.setPhoneType(data[j]);
											} */else if (j == 2) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} else if (j == 3) {
												String[] city = data[j].split("｜");
												if (city != null && city.length > 0) {
													client_imp.setCity(city[0]);
												}
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						} else if (content.indexOf("初始访问") > 1) {
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf1.parse(data[j].trim()));
											} else if (j == 1) {
												client_imp.setCs_url(data[j]);
											} else if (j == 2) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setQq(data[j].replace(".00", ""));
													clientImp2.setQq(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} else if (j == 3) {
												String city = data[j].replace("电信","");
												city = city.replace("联通", "");
												city = city.replace("移动", "");
												client_imp.setCity(city);
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						} else {
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf4.parse("2017-"+data[j].replace("2016", "").replace("2017", "").trim()));
											} else if (j == 1) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setQq(data[j].replace(".00", ""));
													clientImp2.setQq(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} else if (j == 2) {
												client_imp.setFwly(data[j]);
											} else if (j == 3) {
												String city = data[j].replace("电信","");
												city = city.replace("联通", "");
												city = city.replace("移动", "");
												client_imp.setCity(city);
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						}

					}
				}else if(type.equals("02FAC12A4746")){ //百度糯米
					dataList = new ArrayList<String>();
					List<?> list = ExcelUtil.readExcel(files,fileName);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							dataList.add(content);
						}
					}
					JsVote clientImp2 = new JsVote();
					for (int i = 1; i < dataList.size(); i++) {
						if (dataList.get(i) != null
								&& !"".equals(dataList.get(i))) {
							String[] data = dataList.get(i)
									.split(",");
							if (data != null && data.length > 0) {
								client_imp = new JsVote();
								client_imp.setUsername(user.getUsername());
								client_imp.setTui_username(user.getUsername());
								client_imp.setType(type);
								for (int j = 0; j < data.length; j++) {
									if (j == 0) {
										client_imp.setJl_time(sdf4.parse(data[j].trim()));
									} else if (j == 1) {
										client_imp.setCity(data[j]);
									}
									/*else if(j == 2){
										client_imp.setNm_id(data[j].replace(".00", ""));
									}*/ 
									else if (j == 3) {
										if(data[j]!=null && !"".equals(data[j])){
											client_imp.setPhone(data[j].replace(".00", ""));
											clientImp2.setPhone(data[j].replace(".00", ""));
											clientImp2.setSourceTable(1);
											Long count = jsVoteDao.countEqual(clientImp2);
											if(count>0){
												client_imp.setColor("1");
											}
										}
									} /*else if (j == 4) {
										client_imp.setNm_username(data[j].replace(".00", ""));
									}else if (j == 5) {
										client_imp.setNm_zhifu(data[j]);
									}else if (j == 6) {
										client_imp.setNm_sales(data[j].replace(".00", ""));
									}*/
								}
								client_imp.setKeyname(SsiUtils.randomUUID());
								client_imp.setCdate(new Date().getTime()/1000);
								client_imp.setSourceTable(1);
								jsVoteDao.insert(client_imp);
								total++;
							}
						}
					}
				}else if(type.equals("4D189169D77E")){ //百度信息流
					dataList = new ArrayList<String>();
					List<?> list = ExcelUtil.readExcel(files,fileName);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							dataList.add(content);
						}
					}
					JsVote clientImp2 = new JsVote();
					for (int i = 1; i < dataList.size(); i++) {
						if (dataList.get(i) != null
								&& !"".equals(dataList.get(i))) {
							String[] data = dataList.get(i).split(",");
							if (data != null && data.length > 0) {
								client_imp = new JsVote();
								client_imp.setUsername(user.getUsername());
								client_imp.setTui_username(user.getUsername());
								client_imp.setType(type);
								for (int j = 0; j < data.length; j++) {
									if (j == 0) {
										client_imp.setJl_time(sdf4.parse(data[j]));
									} else if(j == 2){
										client_imp.setGg_id(data[j]);
									} else if (j == 3) {
										client_imp.setProvince_city(data[j]);
										client_imp.setProvince(data[j]);
									}else if (j == 4) {
										client_imp.setLianxi_name(data[j]);
									}else if (j == 5) {
										client_imp.setAge(data[j]);
									}else if (j == 6) {
										client_imp.setPhone(data[j]);
										clientImp2.setPhone(data[j].replace(".00", ""));
										clientImp2.setSourceTable(1);
										Long count = jsVoteDao.countEqual(clientImp2);
										if(count>0){
											client_imp.setColor("1");
										}
									}
								}
								client_imp.setKeyname(SsiUtils.randomUUID());
								client_imp.setCdate(new Date().getTime()/1000);
								client_imp.setSourceTable(1);
								jsVoteDao.insert(client_imp);
								total++;
							}
						}
					}
				}else if (type.equals("pmvk5vdc6ity")) {
				    // 商务通未知
					dataList = new ArrayList<String>();
					List<?> list = ExcelUtil.readExcel(files,fileName);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							dataList.add(content);
						}
					}
					JsVote clientImp2 = new JsVote();
					for (int i = 1; i < dataList.size(); i++) {
						if (dataList.get(i) != null
								&& !"".equals(dataList.get(i))) {
							String[] data = dataList.get(i).split(",");
							if (data != null && data.length > 0) {
								client_imp = new JsVote();
								client_imp.setUsername(user.getUsername());
								client_imp.setTui_username(user.getUsername());
								client_imp.setType(type);
								for (int j = 0; j < data.length; j++) {
									if (j == 0) {
										client_imp.setLianxi_name(data[j]);
									} else if(j == 1){
										if(data[j].contains("电话")){
											client_imp.setPhone(data[j].replace(".00", ""));
											clientImp2.setPhone(data[j].replace(".00", ""));
											clientImp2.setSourceTable(1);
											Long count = jsVoteDao.countEqual(clientImp2);
											if(count>0){
												client_imp.setColor("1");
											}	
										}else if(data[j].contains("微信")){
											client_imp.setWeixin(data[j]);
										}else if(data[j].contains("QQ")){
											client_imp.setQq(data[j]);	
										}
										
								} else if (j == 2) {
									client_imp.setCity(data[j]);	

									}else if (j == 5) {
									    String reg = "[\u4e00-\u9fa5]";
									    data[j] = data[j].replaceAll(reg, "");
										client_imp.setJl_time(sdf2.parse(data[j]));


									}else if (j == 4) {
										
									    client_imp.setJd_kefu(data[j]);
									}else if (j == 3) {
									    client_imp.setQudao(data[j]);
									}
								}
								client_imp.setKeyname(SsiUtils.randomUUID());
								client_imp.setCdate(new Date().getTime()/1000);
								client_imp.setSourceTable(1);
								jsVoteDao.insert(client_imp);
								total++;
							}
						}
					}
				}else if(type.equals("SCBTGDT5515")||type.equals("SCBTGJHZY13")||type.equals("ct5yq4jhc6c7")){
				    //市场部(讲座 地推)
				    dataList = new ArrayList<String>();
				    //获取文件数据
					List<?> list = ExcelUtil.readExcel(files,fileName);
					for (int i = 0; i < list.size(); i++) {
						List<?> one = (List<?>) list.get(i);
						if (one != null && one.size() > 0) {
							String content = "";
							for (int j = 0; j < one.size(); j++) {
								if (j == one.size() - 1) {
									content += one.get(j);
								} else {
									content += one.get(j) + ",";
								}
							}
							String contemp = content.replace(",", "");
							//防止出现空表格重复数据
							if(!contemp.isEmpty()){
								dataList.add(content);
							}
						}
					}
					//写入问卷表
					JsVote clientImp2 = new JsVote();
					for (int i = 1; i < dataList.size(); i++) {
						if (dataList.get(i) != null
								&& !"".equals(dataList.get(i))) {
							String[] data = dataList.get(i).split(",");
							if (data != null && data.length > 0) {
								client_imp = new JsVote();
								client_imp.setUsername(user.getUsername());
								client_imp.setTui_username(user.getUsername());
								client_imp.setType(type);
								for (int j = 0; j < data.length; j++) {
									if (j == 0) {
										client_imp.setJl_time(sdf4.parse(data[j]));
									}else if(j == 1){
									    client_imp.setProvince_city(data[j]);
									    client_imp.setCity(data[j]);
									}else if(j == 2){
									    client_imp.setAddress(data[j]);
																				
									}else if (j == 3) {
										
									}else if (j == 4) {
										client_imp.setLianxi_name(data[j]);
									}else if (j == 5) {
										client_imp.setAge(data[j].replace(".00", ""));

									}else if (j == 6) {
										
									}else if (j == 7) {
									    client_imp.setPhone(data[j].replace(".00", ""));
										clientImp2.setPhone(data[j].replace(".00", ""));
										clientImp2.setSourceTable(1);
										Long count = jsVoteDao.countEqual(clientImp2);
										if(count>0){
											client_imp.setColor("1");
										}  
									}else if (j == 8) {
										client_imp.setActivtity_class(data[j]);
									}else if(j == 9) {
										client_imp.setDescs(data[j]);    
									}
									}
								}
								client_imp.setKeyname(SsiUtils.randomUUID());
								client_imp.setCdate(new Date().getTime()/1000);
								client_imp.setSourceTable(1);
								jsVoteDao.insert(client_imp);
								total++;
							}
						}
					}
				//删除下载的文件
				//SFTPUtil.deleteFile(url);
				//多少条数据
				flag = total.toString();
				lx =  type;
		}catch (Exception e) {
			e.printStackTrace();
		}
		return consultant_import(request,flag,lx);
	}
	
	
	/**
	 * @Description:确定导入
	 * @author: Hqd
	 * @date: 2017年11月21日 下午1:12:41 
	 * @return
	 */
	@RequestMapping(value = "/consultant_import_go")
	public ModelAndView consultant_import_go(ModelMap modelMap,@RequestParam("file") final MultipartFile file,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					CommonsMultipartFile cf= (CommonsMultipartFile)file;  
					DiskFileItem fi = (DiskFileItem)cf.getFileItem();  
					File f = fi.getStoreLocation(); 
					String url = request.getParameter("url");//文件名 XXX.xls/XXX.xlsx
					url = Constants.EXCLE_URL + url;
					//上传本地文件到服务器
					InputStream Is = new FileInputStream(f);
					SFTPUtil.getConnection();//获取连接
					String[] arr = url.split("\\.");
					System.out.println(arr[0]);
					//自动生成 文件名
					String filename = MathUtil.getNumberForPK()+"."+arr[1];
					SFTPUtil.upload(Constants.FOLDER_EXCEL, filename, Is);
					url = Constants.FOLDER_EXCEL + filename;
					System.out.println("服务器地址："+url);
					//下载文件到本地
					SFTPUtil.download(Constants.FOLDER_EXCEL, filename, "c:\\"+filename);
					url = "c:\\"+filename;
					String type = request.getParameter("type");
					SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm");
					SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
					SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分ss秒");
					SimpleDateFormat sdf4 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
					SimpleDateFormat sdf5 = new SimpleDateFormat("yyyyMMdd");
					
					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}

					JsVote client_imp = null;
					List<String> dataList = new ArrayList<String>();
					Integer total=0;
						//url = url.replaceAll("//", "/");
						if (type.equals("k4jmt5lbp8ne")) {//400电话
							dataList = new ArrayList<String>();
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									dataList.add(content);
								}
							}
							if (dataList != null && dataList.size() > 0) {
								JsVote clientImp2 = new JsVote();
								TgClient client = new TgClient();
								for (int i = 1; i < dataList.size(); i++) {
									if (dataList.get(i) != null
											&& !"".equals(dataList.get(i))) {
										String[] data = dataList.get(i)
												.split(",");
										if (data != null && data.length > 0) {
											client_imp = new JsVote();
											client_imp.setUsername(user.getUsername());
											client_imp.setTui_username(user.getUsername());
											client_imp.setType(type);
											for (int j = 0; j < data.length; j++) {
												if (j == 0) {
													client_imp.setLianxi_name(data[j]);
												} else if (j == 1) {
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
													client.setPhone(data[j].replace(".00", ""));
													Integer count2 = clientDao.getClientCount(client);
													if(count2>0){
														client_imp.setColor("1");
													}
												} else if (j == 2) {
													client_imp.setCity(data[j]);
												} else if (j == 3) {
													client_imp.setJl_time(sdf4.parse(data[j]));
												} else if (j == 4) {
													client_imp.setStudent_msg(data[j]);
												} 
											}
											client_imp.setKeyname(SsiUtils.randomUUID());
											client_imp.setCdate(new Date().getTime()/1000);
											client_imp.setSourceTable(1);
											jsVoteDao.insert(client_imp);
											total++;
										}
									}
								}
							}
						} else if (type.equals("baiduxunke")) {// 百度寻客
							dataList = ReadExcel.importCsv(new File(url));
							if (dataList != null && dataList.size() > 0) {
								JsVote clientImp2 = new JsVote();
								for (int i = 1; i < dataList.size(); i++) {
									if (dataList.get(i) != null
											&& !"".equals(dataList.get(i))) {
										String[] data = dataList.get(i).split(
												",");
										if (data != null && data.length > 0) {
											client_imp = new JsVote();
											client_imp.setUsername(user.getUsername());
											client_imp.setTui_username(user.getUsername());
											client_imp.setType(type);
											for (int j = 0; j < data.length; j++) {
												if (j == 0) {
													client_imp.setJl_time(sdf1.parse(data[j].trim()));
												} else if (j == 1) {
													if(data[j]!=null && !"".equals(data[j])){
														client_imp.setPhone(data[j].replace(".00", ""));
														clientImp2.setPhone(data[j].replace(".00", ""));
														clientImp2.setSourceTable(1);
														Long count = jsVoteDao.countEqual(clientImp2);
														if(count>0){
															client_imp.setColor("1");
														}
													}
												} else if (j == 2) {
													client_imp.setLianxi_name(data[j]);
												} else if (j == 4) {
													client_imp.setCity(data[j]);
												} else if (j == 5) {
													client_imp.setKeyword(data[j]);
												}
											}
											client_imp.setKeyname(SsiUtils.randomUUID());
											client_imp.setCdate(new Date().getTime()/1000);
											client_imp.setSourceTable(1);
											jsVoteDao.insert(client_imp);
											total++;
										}
									}
								}
							}
						}
						/*else if (type.equals("ct5yq4jhc6c7")) {	// 市场部推广(讲座)
							dataList = ReadExcel.importCsv(new File(url));
							if (dataList != null && dataList.size() > 0) {
								JsVote clientImp2 = new JsVote();
								for (int i = 1; i < dataList.size(); i++) {
									if (dataList.get(i) != null
											&& !"".equals(dataList.get(i))) {
										String[] data = dataList.get(i).split(
												",");
										if (data != null && data.length > 0) {
											client_imp = new JsVote();
											client_imp.setUsername(user.getUsername());
											client_imp.setTui_username(user.getUsername());
											client_imp.setType(type);
											for (int j = 0; j < data.length; j++) {
												if (j == 0) {
													client_imp.setJl_time(sdf1.parse(data[j].trim()));
												} else if (j == 1) {
													if(data[j]!=null && !"".equals(data[j])){
														client_imp.setPhone(data[j].replace(".00", ""));
														clientImp2.setPhone(data[j].replace(".00", ""));
														clientImp2.setSourceTable(1);
														Long count = jsVoteDao.countEqual(clientImp2);
														if(count>0){
															client_imp.setColor("1");
														}
													}
												} else if (j == 2) {
													client_imp.setLianxi_name(data[j]);
												} else if (j == 4) {
													client_imp.setCity(data[j]);
												} else if (j == 5) {
													client_imp.setKeyword(data[j]);
												}
											}
											client_imp.setKeyname(SsiUtils.randomUUID());
											client_imp.setCdate(new Date().getTime()/1000);
											client_imp.setSourceTable(1);
											jsVoteDao.insert(client_imp);
											total++;
										}
									}
								}
							}
						}*/else if (type.equals("frvmppoifgmb")) {// 今日头条
							try {
								dataList = new ArrayList<String>();
								dataList = ReadExcel.importCsv(new File(url));
								if (dataList != null && dataList.size() > 0) {
									JsVote clientImp2 = new JsVote();
									for (int i = 1; i < dataList.size(); i++) {
										if (dataList.get(i) != null
												&& !"".equals(dataList.get(i))) {
											String[] data = dataList.get(i)
													.split(",");
											if (data != null && data.length > 0) {
												client_imp = new JsVote();
												client_imp.setUsername(user.getUsername());
												client_imp.setTui_username(user.getUsername());
												client_imp.setType(type);
												
												for (int j = 0; j < data.length; j++) {
													if (j == 1) {
														client_imp.setGg_id(data[j]+"");
													} else if (j == 2) {
														client_imp.setLianxi_name(data[j]);
													} else if (j == 3) {
														if(data[j]!=null && !"".equals(data[j])){
															client_imp.setPhone(data[j].replace(".00", ""));
															clientImp2.setPhone(data[j].replace(".00", ""));
															clientImp2.setSourceTable(1);
															Long count = jsVoteDao.countEqual(clientImp2);
															if(count>0){
																client_imp.setColor("1");
															}
														}
													} else if (j == 4) {
														client_imp.setAge(data[j]);
													} else if (j == 5) {
														client_imp.setCity(data[j]);
													} else if (j == 6) {
														String[] dax = data[j].split(":");
														if(dax!=null && dax.length==2){
															try {
																client_imp.setJl_time(sdf4.parse(data[j].trim()+":00"));
															} catch (ParseException e) {
																client_imp.setJl_time(sdf1.parse(data[j].trim()+":00"));
																}
														}else{
															try {
																client_imp.setJl_time(sdf4.parse(data[j].trim()));
															} catch (ParseException e) {
																client_imp.setJl_time(sdf1.parse(data[j].trim()));
															}
															
														}
													}
												}
												client_imp.setKeyname(SsiUtils.randomUUID());
												client_imp.setCdate(new Date().getTime()/1000);
												client_imp.setSourceTable(1);
												jsVoteDao.insert(client_imp);
												total++;
											}
										}
									} 
								} 
							} catch (Exception e) {
								e.printStackTrace();
							} 
						} else if (type.equals("lixianbao")) {// 离线宝
							try {
								dataList = new ArrayList<String>();
								List<?> list = ExcelUtil
										.readExcel(new File(url));
								for (int i = 0; i < list.size(); i++) {
									List<?> one = (List<?>) list.get(i);
									if (one != null && one.size() > 0) {
										String content = "";
										for (int j = 0; j < one.size(); j++) {
											if (j == one.size() - 1) {
												content += one.get(j);
											} else {
												content += one.get(j) + ",";
											}
										}
										dataList.add(content);
									}
								}
								if (dataList != null && dataList.size() > 0) {
									JsVote clientImp2 = new JsVote();
									for (int i = 1; i < dataList.size(); i++) {
										if (dataList.get(i) != null
												&& !"".equals(dataList.get(i))) {
											String[] data = dataList.get(i)
													.split(",");
											if (data != null && data.length > 0) {
												client_imp = new JsVote();
												client_imp.setUsername(user.getUsername());
												client_imp.setTui_username(user.getUsername());
												client_imp.setType(type);
												for (int j = 0; j < data.length; j++) {
													/*if (j == 0) {
														client_imp.setPhoneType(data[j]);
													} else if (j == 1) {
														client_imp.setMeitily(data[j]);
													} else if (j == 2) {
														client_imp.setJihua(data[j]);
													} else if (j == 3) {
														client_imp.setDanyuan(data[j]);
													} else if (j == 4) {
														client_imp.setFenjihao(data[j]);
													} else */if (j == 5) {
														if(data[j]!=null && !"".equals(data[j])){
															client_imp.setPhone(data[j].replace(".00", ""));
															clientImp2.setPhone(data[j].replace(".00", ""));
															clientImp2.setSourceTable(1);
															Long count = jsVoteDao.countEqual(clientImp2);
															if(count>0){
																client_imp.setColor("1");
															}
														}
													} /*else if (j == 6) {
														client_imp.setBj_phone(data[j]);
													} else*/ if (j == 7) {
														client_imp.setCity(data[7]);
													} else if (j == 8) {
														client_imp.setCity(data[7]+ " "+ data[8]);
													} else if (j == 9) {
														client_imp.setJl_time(sdf4.parse(data[j].trim()));
													} /*else if (j == 10) {
														client_imp.setTh_end(data[j]);
														client_imp.setJl_time(sdf4.parse(data[j].trim()));
													} else if (j == 11) {
														client_imp.setTh_timeL(data[j]);
													} else if (j == 12) {
														client_imp.setTh_money(data[j]);
													} else if (j == 13) {
														client_imp.setTh_state(data[j]);
													} else if (j == 14) {
														client_imp.setTh_dengdai(data[j]);
													}*/ else if (j == 15) {
														client_imp.setIp(data[j]);
													} /*else if (j == 16) {
														client_imp.setIp_city(data[16]+ " "+ data[17]);
													} else if (j == 18) {
														client_imp.setSb_type(data[j]);
													} else if (j == 19) {
														client_imp.setShebei(data[j]);
													} else if (j == 20) {
														client_imp.setSb_xitong(data[j]);
													} else if (j == 21) {
														client_imp.setSite(data[j]);
													} else if (j == 22) {
														client_imp.setTj_url(data[j]);
													}*/
												}
												client_imp.setKeyname(SsiUtils.randomUUID());
												client_imp.setCdate(new Date().getTime()/1000);
												client_imp.setSourceTable(1);
												jsVoteDao.insert(client_imp);
												total++;
											}
										}
									}
								}
							} catch (IOException e) {
								e.printStackTrace();
							}
						} else if (type.equals("shangqiaogt")) {// 商桥沟通客户
							dataList = WriterExcel.readExcel(url);
							if (dataList != null && dataList.size() > 0) {
								JsVote clientImp2 = new JsVote();
								for (int i = 4; i < dataList.size(); i++) {
									if (dataList.get(i) != null
											&& !"".equals(dataList.get(i))) {
										String[] data = dataList.get(i).split(
												",");
										if (data != null && data.length > 0) {
											client_imp = new JsVote();
											client_imp.setUsername(user.getUsername());
											client_imp.setTui_username(user.getUsername());
											client_imp.setType(type);
											
											JsVote clientImp3 = new JsVote();
											for (int j = 0; j < data.length; j++) {
												/*if (j == 1) {
													client_imp.setFw_start(data[j]);
												} else if (j == 2) {
													client_imp.setTh_start(data[j]);
													client_imp.setJl_time(sdf3.parse(data[j].trim()));
												} else*/
												if (j == 3) {
													client_imp.setLianxi_name(data[j]);
												} else if (j == 4) {
													if(data[j]!=null && !"".equals(data[j])){
														client_imp.setPhone(data[j].replace(".00", ""));
														clientImp2.setPhone(data[j].replace(".00", ""));
														clientImp2.setSourceTable(1);
														Long count = jsVoteDao.countEqual(clientImp2);
														if(count>0){
															client_imp.setColor("1");
														}
													}
												} else if (j == 5) {
													if(data[j]!=null && !"".equals(data[j])){
														client_imp.setQq(data[j].replace(".00", ""));
														clientImp3.setQq(data[j].replace(".00", ""));
														clientImp2.setSourceTable(1);
														Long count = jsVoteDao.countEqual(clientImp2);
														if(count>0){
															client_imp.setColor("1");
														}
													}
												} else if (j == 6) {
													client_imp.setFwly(data[j]);
												} else if (j == 7) {
													client_imp.setCs_url(data[j]);
												} else if (j == 8) {
													client_imp.setKeyword(data[j]);
												} /*else if (j == 9) {
													client_imp.setSs_keyword(data[j]);
												}*/
											}
											client_imp.setKeyname(SsiUtils.randomUUID());
											client_imp.setCdate(new Date().getTime()/1000);
											client_imp.setSourceTable(1);
											jsVoteDao.insert(client_imp);
											total++;
										}
									}
								}
							}
						} else if (type.equals("edhhjon7t6za")) {// 商桥留言
							dataList = ReadExcel.importCsv(new File(url));
							if (dataList != null && dataList.size() > 0) {
								client_imp = new JsVote();
								client_imp.setUsername(user.getUsername());
								client_imp.setTui_username(user.getUsername());
								client_imp.setType(type);
								JsVote clientImp2 = new JsVote();
								for (int i = 1; i < dataList.size(); i++) {
									String[] data = dataList.get(i).split(",");
									for(int j=0;j<data.length;j++){
										if(j==0){
											client_imp.setJl_time(sdf4.parse(data[j].trim()));
										}else if(j==1){
											client_imp.setCity(data[j]);
										}else if(j==2){
											client_imp.setFwly(data[j]);
										}else if(j==3){
											client_imp.setKeyword(data[j]);
										}
										/*else if(j==4){
											client_imp.setSite(data[j]);
										}else if(j==5){
											client_imp.setTj_url(data[j]);
										}*/else if(j==6){
											client_imp.setLianxi_name(data[j]);
										}else if(j==7){
											if(data[j]!=null && !"".equals(data[j])){
												client_imp.setPhone(data[j].replace(".00", ""));
												clientImp2.setPhone(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}
											}
										}else if(j==8){
											client_imp.setAddress(data[j]);
										}else if(j==9){
											client_imp.setEmail(data[j]);
										}/*else if(j==10){
											client_imp.setMsg(data[j]);
										}else if(j==11){
											client_imp.setBeizhu(data[j]);
										}else if(j==12){
											client_imp.setGt_state(data[j]);
										}*/
									}
									client_imp.setCdate(new Date().getTime()/1000);
									client_imp.setSourceTable(1);
									jsVoteDao.insert(client_imp);
									total++;
								}
								
							}
						} else if (type.equals("yunxiaoke")) {// 云销客
							dataList = new ArrayList<String>();
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									dataList.add(content);
								}
							}
							if (dataList != null && dataList.size() > 0) {
								String content = dataList.get(0);
								if (content.indexOf("手机型号") > 1) {
									JsVote clientImp2 = new JsVote();
									for (int i = 1; i < dataList.size(); i++) {
										if (dataList.get(i) != null
												&& !"".equals(dataList.get(i))) {
											String[] data = dataList.get(i)
													.split(",");
											if (data != null && data.length > 0) {
												client_imp = new JsVote();
												client_imp.setUsername(user.getUsername());
												client_imp.setTui_username(user.getUsername());
												client_imp.setType(type);
												for (int j = 0; j < data.length; j++) {
													if (j == 0) {
														client_imp.setJl_time(sdf4.parse("2017-"+data[j].trim()));
													} /*else if (j == 1) {
														client_imp.setPhoneType(data[j]);
													} */else if (j == 2) {
														if(data[j]!=null && !"".equals(data[j])){
															client_imp.setPhone(data[j].replace(".00", ""));
															clientImp2.setPhone(data[j].replace(".00", ""));
															clientImp2.setSourceTable(1);
															Long count = jsVoteDao.countEqual(clientImp2);
															if(count>0){
																client_imp.setColor("1");
															}
														}
													} else if (j == 3) {
														String[] city = data[j].split("｜");
														if (city != null && city.length > 0) {
															client_imp.setCity(city[0]);
														}
													}
												}
												client_imp.setKeyname(SsiUtils.randomUUID());
												client_imp.setCdate(new Date().getTime()/1000);
												client_imp.setSourceTable(1);
												jsVoteDao.insert(client_imp);
												total++;
											}
										}
									}
								} else if (content.indexOf("初始访问") > 1) {
									JsVote clientImp2 = new JsVote();
									for (int i = 1; i < dataList.size(); i++) {
										if (dataList.get(i) != null
												&& !"".equals(dataList.get(i))) {
											String[] data = dataList.get(i)
													.split(",");
											if (data != null && data.length > 0) {
												client_imp = new JsVote();
												client_imp.setUsername(user.getUsername());
												client_imp.setTui_username(user.getUsername());
												client_imp.setType(type);
												for (int j = 0; j < data.length; j++) {
													if (j == 0) {
														client_imp.setJl_time(sdf1.parse(data[j].trim()));
													} else if (j == 1) {
														client_imp.setCs_url(data[j]);
													} else if (j == 2) {
														if(data[j]!=null && !"".equals(data[j])){
															client_imp.setQq(data[j].replace(".00", ""));
															clientImp2.setQq(data[j].replace(".00", ""));
															clientImp2.setSourceTable(1);
															Long count = jsVoteDao.countEqual(clientImp2);
															if(count>0){
																client_imp.setColor("1");
															}
														}
													} else if (j == 3) {
														String city = data[j].replace("电信","");
														city = city.replace("联通", "");
														city = city.replace("移动", "");
														client_imp.setCity(city);
													}
												}
												client_imp.setKeyname(SsiUtils.randomUUID());
												client_imp.setCdate(new Date().getTime()/1000);
												client_imp.setSourceTable(1);
												jsVoteDao.insert(client_imp);
												total++;
											}
										}
									}
								} else {
									JsVote clientImp2 = new JsVote();
									for (int i = 1; i < dataList.size(); i++) {
										if (dataList.get(i) != null
												&& !"".equals(dataList.get(i))) {
											String[] data = dataList.get(i)
													.split(",");
											if (data != null && data.length > 0) {
												client_imp = new JsVote();
												client_imp.setUsername(user.getUsername());
												client_imp.setTui_username(user.getUsername());
												client_imp.setType(type);
												for (int j = 0; j < data.length; j++) {
													if (j == 0) {
														client_imp.setJl_time(sdf4.parse("2017-"+data[j].replace("2016", "").replace("2017", "").trim()));
													} else if (j == 1) {
														if(data[j]!=null && !"".equals(data[j])){
															client_imp.setQq(data[j].replace(".00", ""));
															clientImp2.setQq(data[j].replace(".00", ""));
															clientImp2.setSourceTable(1);
															Long count = jsVoteDao.countEqual(clientImp2);
															if(count>0){
																client_imp.setColor("1");
															}
														}
													} else if (j == 2) {
														client_imp.setFwly(data[j]);
													} else if (j == 3) {
														String city = data[j].replace("电信","");
														city = city.replace("联通", "");
														city = city.replace("移动", "");
														client_imp.setCity(city);
													}
												}
												client_imp.setKeyname(SsiUtils.randomUUID());
												client_imp.setCdate(new Date().getTime()/1000);
												client_imp.setSourceTable(1);
												jsVoteDao.insert(client_imp);
												total++;
											}
										}
									}
								}

							}
						}else if(type.equals("02FAC12A4746")){ //百度糯米
							dataList = new ArrayList<String>();
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									dataList.add(content);
								}
							}
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i)
											.split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf4.parse(data[j].trim()));
											} else if (j == 1) {
												client_imp.setCity(data[j]);
											}
											/*else if(j == 2){
												client_imp.setNm_id(data[j].replace(".00", ""));
											}*/ 
											else if (j == 3) {
												if(data[j]!=null && !"".equals(data[j])){
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}
												}
											} /*else if (j == 4) {
												client_imp.setNm_username(data[j].replace(".00", ""));
											}else if (j == 5) {
												client_imp.setNm_zhifu(data[j]);
											}else if (j == 6) {
												client_imp.setNm_sales(data[j].replace(".00", ""));
											}*/
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						}else if(type.equals("4D189169D77E")){ //百度信息流
							dataList = new ArrayList<String>();
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									dataList.add(content);
								}
							}
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i).split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf4.parse(data[j]));
											} else if(j == 2){
												client_imp.setGg_id(data[j]);
											} else if (j == 3) {
												client_imp.setProvince_city(data[j]);
												client_imp.setProvince(data[j]);
											}else if (j == 4) {
												client_imp.setLianxi_name(data[j]);
											}else if (j == 5) {
												client_imp.setAge(data[j]);
											}else if (j == 6) {
												client_imp.setPhone(data[j]);
												clientImp2.setPhone(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						}else if (type.equals("pmvk5vdc6ity")) {
						    // 商务通未知
							dataList = new ArrayList<String>();
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									dataList.add(content);
								}
							}
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i).split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setLianxi_name(data[j]);
											} else if(j == 1){
												if(data[j].contains("电话")){
													client_imp.setPhone(data[j].replace(".00", ""));
													clientImp2.setPhone(data[j].replace(".00", ""));
													clientImp2.setSourceTable(1);
													Long count = jsVoteDao.countEqual(clientImp2);
													if(count>0){
														client_imp.setColor("1");
													}	
												}else if(data[j].contains("微信")){
													client_imp.setWeixin(data[j]);
												}else if(data[j].contains("QQ")){
													client_imp.setQq(data[j]);	
												}
												
										} else if (j == 2) {
											client_imp.setCity(data[j]);	

											}else if (j == 5) {
											    String reg = "[\u4e00-\u9fa5]";
											    data[j] = data[j].replaceAll(reg, "");
												client_imp.setJl_time(sdf2.parse(data[j]));


											}else if (j == 4) {
												
											    client_imp.setJd_kefu(data[j]);
											}else if (j == 3) {
											    client_imp.setQudao(data[j]);
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						}else if(type.equals("SCBTGDT5515")||type.equals("SCBTGJHZY13")||type.equals("ct5yq4jhc6c7")){
						    //市场部(讲座 地推)
						    dataList = new ArrayList<String>();
						    //获取文件数据
							List<?> list = ExcelUtil.readExcel(new File(url));
							for (int i = 0; i < list.size(); i++) {
								List<?> one = (List<?>) list.get(i);
								if (one != null && one.size() > 0) {
									String content = "";
									for (int j = 0; j < one.size(); j++) {
										if (j == one.size() - 1) {
											content += one.get(j);
										} else {
											content += one.get(j) + ",";
										}
									}
									String contemp = content.replace(",", "");
									//防止出现空表格重复数据
									if(!contemp.isEmpty()){
										dataList.add(content);
									}
								}
							}
							//写入问卷表
							JsVote clientImp2 = new JsVote();
							for (int i = 1; i < dataList.size(); i++) {
								if (dataList.get(i) != null
										&& !"".equals(dataList.get(i))) {
									String[] data = dataList.get(i).split(",");
									if (data != null && data.length > 0) {
										client_imp = new JsVote();
										client_imp.setUsername(user.getUsername());
										client_imp.setTui_username(user.getUsername());
										client_imp.setType(type);
										for (int j = 0; j < data.length; j++) {
											if (j == 0) {
												client_imp.setJl_time(sdf4.parse(data[j]));
											}else if(j == 1){
											    client_imp.setProvince_city(data[j]);
											    client_imp.setCity(data[j]);
											}else if(j == 2){
											    client_imp.setAddress(data[j]);
																						
											}else if (j == 3) {
												
											}else if (j == 4) {
												client_imp.setLianxi_name(data[j]);
											}else if (j == 5) {
												client_imp.setAge(data[j].replace(".00", ""));

											}else if (j == 6) {
												
											}else if (j == 7) {
											    client_imp.setPhone(data[j].replace(".00", ""));
												clientImp2.setPhone(data[j].replace(".00", ""));
												clientImp2.setSourceTable(1);
												Long count = jsVoteDao.countEqual(clientImp2);
												if(count>0){
													client_imp.setColor("1");
												}  
											}else if (j == 8) {
											    client_imp.setDescs(data[j]);  
											}
											}
										}
										client_imp.setKeyname(SsiUtils.randomUUID());
										client_imp.setCdate(new Date().getTime()/1000);
										client_imp.setSourceTable(1);
										jsVoteDao.insert(client_imp);
										total++;
									}
								}
							}
						result.setDefaultModel("dataList", dataList);
						result.setDefaultModel("total", total);
						//删除下载的文件
						SFTPUtil.deleteFile(url);
					
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}
	

	/**
	 * @Description:资源汇总 ->> 客户资源 列表
	 * @author: Hqd
	 * @date: 2017年11月10日 下午2:59:09 
	 * @return
	 */
	@RequestMapping(value = "/consultant_import_list")
	public ModelAndView consultant_import_list(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					TgClientImp clientImp = new TgClientImp();
					String type = request.getParameter("type");
					String haiQx = request.getParameter("haiQx"); 
					String lianxi_name = request.getParameter("lianxi_name");
					String phone = request.getParameter("phone");
					String state = request.getParameter("state");
					String tui_nickname = request.getParameter("tui_nickname");
					String st_type = request.getParameter("st_type");
					String color = request.getParameter("color");
					String state1 = request.getParameter("stat");
					String teacherName = request.getParameter("teacherName");
					String stardate = request.getParameter("stardate");
					String enddate = request.getParameter("enddate");
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					
					TgUser user = UserUtil.getUserFromCookies();
					if (user == null) {
						return result;
					}
					
					if(haiQx!=null && haiQx.equals("1")){
						if(user.getMenu()!=null){
							String type2 = "";
							if(user.getMenu().contains("i")){
								type2 += "lixianbao,";
							}
							if(user.getMenu().contains("j")){
								type2 += "02FAC12A4746,";
							}
							if(user.getMenu().contains("k")){
								type2 += "frvmppoifgmb,";
							}
							if(user.getMenu().contains("x")){
								type2 += "4D189169D77E";
							}
							result.setDefaultModel("type2", type2);
							
							
							if(type!=null && !"".equals(type)){
								clientImp.setType2(type);
							}else{
								clientImp.setType2(type2);
							}
						}
						result.setDefaultModel("haiQx", haiQx);
					}else{
						clientImp.setType(type);
					}
					
					if(user.getUsergroup()==2){
						clientImp.setUsername(user.getUsername());
					}
					
					if(color!=null && !color.equals("")){
						clientImp.setColor("1");
					}
					
					if(st_type!=null && !st_type.equals("")){
						clientImp.setSt_type(Integer.valueOf(st_type));
					}
					
					if(stardate!=null && !stardate.equals("")){
						clientImp.setStartTime(stardate);
					}
					
					if(enddate!=null && !enddate.equals("")){
						clientImp.setEndTime(sdf.format(DateUtil.getTommorrowDay1(sdf.parse(enddate))));
					}
					//已分配老师下拉传过来的字符串
					if(teacherName != null && !"".equals(teacherName)){
						clientImp.setTo_nickname(teacherName);
					}
					//判断客户状态
					if((state1!=null && !"".equals(state1))){
						result.setDefaultModel("state1", state1);
						if((state1.equals("已预约"))){
							clientImp.setRenum(2);
							clientImp.setRemin(1);
						}else if(state1.equals("未出现") ){
							clientImp.setRenum(3);
							clientImp.setRemin(3);
						}else if(state1.equals("已缴费")){
							clientImp.setRecenum(6);
							clientImp.setRecemin(6);
						}else if(state1.equals("已测评")){
							clientImp.setRecenum(5);
							clientImp.setRecemin(1);
						}else if(state1.equals("无")){
							//设置0让其他几个值为空
							clientImp.setRenum_n(0);
						}
					}
					
					clientImp.setLianxi_name(lianxi_name);
					clientImp.setPhone(phone);
					clientImp.setState(state);
					if(tui_nickname !=null && !"".equals(tui_nickname)){
						if(tui_nickname.contains("严马")){
							clientImp.setTui_nickname("yanma");
						}else if(tui_nickname.contains("郭斌")){
							clientImp.setTui_nickname("guobin");
						}else if(tui_nickname.contains("宋子豪")){
							clientImp.setTui_nickname("songzihao");
						}else if(tui_nickname.contains("陈涵")){
							clientImp.setTui_nickname("chenhan");
						}else if(tui_nickname.contains("刘河川")){
							clientImp.setTui_nickname("liuhechuan");
						}else if(tui_nickname.contains("孙果")){
							clientImp.setTui_nickname("sunguo2");
						}else{
							
						}
					}
					if(haiQx==null){
						if(!user.getDepartments().equals("竞思总部") && !user.getUsername().equals("he")){
							clientImp.setJob2(user.getDepartments());
						}
					}
					Integer currPage = 1;
					if (vo.getCurrPage() != null && !"".equals(vo.getCurrPage())) {
						currPage = vo.getCurrPage();
					}
					
					Integer total = clientImpDao.getClientListImpCByType(clientImp);
					Page page = PageUtil.createPage(10, currPage, total);
					List<TgClientImp> list = clientImpDao.getClientListImpByType(clientImp, page);
					if(list!=null && list.size()>0){
						for(TgClientImp clientP:list){
							if(!user.getUsername().equals("admin")){
									//客户状态
									String stat="";
									if(clientP.getState1()!=null && !"".equals(clientP.getState1())){
										int renum = clientP.getState1();
										if(renum >= 1 && renum <= 2){
											stat = "已预约";
										}else if(renum==3){
											stat = "未出现";
										}
										clientP.setStates(stat);
									}
									
									if(clientP.getWorths()!=null && !"".equals(clientP.getWorths())){
										Integer recenum =Integer.valueOf(clientP.getWorths());
										if(recenum == 6){
											if(stat!=""){
												stat =stat+","+"已缴费";
											}else{
												stat ="已缴费";
											}
										}else if(0<recenum  && recenum <=5){
											if(stat!=""){
												stat =stat+","+"已测评";
											}else{
												stat ="已测评";
											}
										}
										clientP.setStates(stat);
									}
		   	   					
		   	   				//跟踪情况
		   	   				if ( clientP.getLast_track() != null && !"".equals( clientP.getLast_track())) {
								clientP.setLast_track(clientP.getLast_track().replace("&nbsp;","").trim());
								if(StringUtil.isNum(clientP.getLast_track())){
									clientP.setFallow(clientP.getLast_track());
								}else{
								boolean flag = StringUtil.getHanzi(clientP.getLast_track().replaceAll("</?[^<]+>", ""));
								if (!flag) {
										byte[] bytes = StringUtil.hexDecode(clientP.getLast_track());
										String ObjContent = new String(bytes,"UTF-8");
										clientP.setFallow(ObjContent);
								}else {
									clientP.setFallow(clientP.getLast_track());
									}
								}
								if(clientP.getFallow().contains("\"")){
									clientP.setFallow(clientP.getFallow().replace('"',' '));
								}
								
							}
							}
						}
					}
					List<TgSource> sourcelist = sourceDao.getAll();
					
					result.setDefaultModel("sourcelist", sourcelist);
					result.setDefaultModel("list", list);
					result.setDefaultModel("page", page);
					result.setDefaultModel("type", type);
					result.setDefaultModel("statez", state1);
					result.setDefaultModel("tui_nickname", tui_nickname);
					result.setDefaultModel("clientImp", clientImp);
					result.setDefaultModel("currPage", currPage);
					result.setDefaultModel("stardate", stardate);
					result.setDefaultModel("enddate", enddate);
					result.setDefaultModel("teacherName",teacherName);
				} catch (Exception e) {
					e.printStackTrace();
				}
				return result;
			}
		});

		return new ModelAndView("consultant/consultant_import_list", modelMap);
	}

	// 客户资源分配详情页
	@RequestMapping(value = "/consultant_import_allot")
	public ModelAndView consultant_import_detail(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = WebExecutor.execute(logger, vo, new Biz() {
			public Result process() {
				Result result = new ResultSupport(true);
				String id = request.getParameter("id");
				String currPage = request.getParameter("currPage");
				if(id!=null && !"".equals(id)){
					JsVote  clientImp = jsVoteDao.findById(JsVote.class, Long.valueOf(id));
					if(clientImp!=null){
						
						TgClient client = new TgClient();
						Long a=0L;Long b=0L;Long c=0L;
						if(clientImp.getPhone()!=null && !"".equals(clientImp.getPhone())){
							TgClient client1 = new TgClient();
							client1.setPhone(clientImp.getPhone());
							client.setPhone(clientImp.getPhone());
							a = clientDao.countEqual(client1);
						}
						if(clientImp.getWeixin()!=null && !"".equals(clientImp.getWeixin())){
							TgClient client2 = new TgClient();
							client2.setWeixin(clientImp.getWeixin());
							client.setWeixin(clientImp.getWeixin());
							b = clientDao.countEqual(client2);
						}
						if(clientImp.getQq()!=null && !"".equals(clientImp.getQq())){
							TgClient client3 = new TgClient();
							client3.setQq(clientImp.getQq());
							client.setQq(clientImp.getQq());
							c = clientDao.countEqual(client3);
						}
						
						Long total = a+b+c;
						if(total>0){
							result.setDefaultModel("total", "1");
							List<TgClient> clist = clientDao.getClientallot(client);
							result.setDefaultModel("clist",clist);
						}
						
						if(clientImp.getTui_username()!=null && !"".equals(clientImp.getTui_username())){
							TgUserinfo userinfo = new TgUserinfo();
							userinfo.setUsername(clientImp.getTui_username());
							List<TgUserinfo> infoList = userinfoDao.findByExample(userinfo);
							if(infoList!=null && infoList.size()>0){
								String nickName = infoList.get(0).getNickname();
								clientImp.setTui_nickName(nickName);
							}
						}
						
					}
					
					TgUserinfo user  = new TgUserinfo();
	   				user.setJob("课程顾问");
	   				List<TgUserinfo> uList =userinfoDao.getUserInfoByUserInfo(user);
	   				
	   				TgUserinfo user1  = new TgUserinfo();
	   				user1.setJob("在线课程顾问");
	   				List<TgUserinfo> uList1 =userinfoDao.getUserInfoByUserInfo(user1);
	   				
	   				
	   				result.setDefaultModel("clientImp", clientImp);
	   				result.setDefaultModel("uList", uList);
	   				result.setDefaultModel("uList1", uList1);
	   				result.setDefaultModel("currPage", currPage);
				}
				return result;
			}
		});
		return new ModelAndView("consultant/consultant_import_allot", modelMap);
	}
	
	/**
	 * @Description:批量分配操作
	 * @author: Hqd
	 * @date: 2017年11月22日 上午11:47:57 
	 * @return
	 */
	@RequestMapping(value = "/import_plfp")
	public void downloadPlan(ModelMap modelMap, final BaseVo vo,
			final HttpServletRequest request, final HttpServletResponse response) throws Exception {
		String flag = "true";
		try{
			//客户id 以','分割
			String ids = request.getParameter("ids");
			//分配到老师的姓名
			String zxs_name = request.getParameter("zxs_name");
			//查询 咨询师每天管理客户上线量
			String result = checkSxian(zxs_name);
			if(!"true".equals(result)){//返回失败
				flag = result;
			}else{//返回成功执行下面的
				String[] idArr = ids.split(",");
				for(String id : idArr){
					//获取客户对象
					JsVote jsVote = jsVoteDao.findById(JsVote.class, Long.parseLong(id));
					if(jsVote != null){
						//添加客户资料
						add_TgClient(jsVote, zxs_name);
						//修改分配信息
						jsVote.setTo_time(new Date());//设置分配时间
						jsVote.setTo_username(zxs_name);
						jsVote.setGo_username(UserUtil.getUserFromCookies().getUsername());
						jsVote.setState(Constants.STATE_1);
						jsVoteDao.update(jsVote);//更新
					}
				}
			}
		}catch (Exception e) {
			e.printStackTrace();
		}
		PrintWriter out = response.getWriter();//定义out
		out.print(flag);
	}
	/**
	 * @Description:判断  分配给咨询师后的客户上限量是否大于 每天管理客户上线量（sxian 有数据的）
	 * @author: Hqd
	 * @date: 2017年11月22日 下午1:14:38 
	 * @return
	 * @throws ParseException 
	 */
	public String checkSxian(String zxs_name) throws ParseException {
		String	startTime = Constants.sdf.format(new Date());
		String	endTime = Constants.sdf.format(DateUtil.getTommorrowDay1(Constants.sdf.parse(startTime)));
		//客户资源
		TgClientImp clientimp = new TgClientImp();
		clientimp.setTo_username(zxs_name);
		clientimp.setTo_startTime(startTime);
		clientimp.setTo_endTime(endTime);
		List<TgClientImp> clientImpList = clientImpDao.getClientImpByType(clientimp);
			
		TgUserinfo info = new TgUserinfo();
		info.setUsername(zxs_name);
		List<TgUserinfo> infoList =userinfoDao.findByExample(info);
		if(infoList!=null && infoList.size()>0){
			String sxian = infoList.get(0).getSxian();
			if(sxian==null || "".equals(sxian)){
				sxian = Constants.TOPLIMIT_KH;//设置上限个数
			}
			if(clientImpList.size()>=Integer.valueOf(sxian)){
				return Constants.ERROR_MSG_1;
			}
		}
		return "true";
	}
	/**
	 * @Description:添加客户资料
	 * @author: Hqd
	 * @date: 2017年11月22日 下午2:15:20 
	 * @return
	 */
	public void add_TgClient(JsVote jsVote,String zxs_name) {
		TgClient client = new TgClient();
		client.setType(Constants.TG_CLIENT_TYPE_3);
		client.setFrom_id(jsVote.getId());
		client.setKeyname(jsVote.getKeyname());
		client.setNickname(jsVote.getLianxi_name());
		client.setRawusername(jsVote.getUsername());
		client.setLodusername(zxs_name);
		client.setUsername(zxs_name);
		client.setSource(jsVote.getType());
		client.setProvince(jsVote.getProvince());
		client.setCity(jsVote.getCity());
		client.setPhone(jsVote.getPhone());
		client.setWeixin(jsVote.getWeixin());
		client.setQq(jsVote.getQq());
		client.setDescs("孩子情况："+jsVote.getStudent_msg()+"。其他:"+jsVote.getDescs());
		client.setCdate(new Date().getTime()/1000);
		clientDao.insert(client);
	}
	
	/**
	 * @Description:客户资源资源分配操作
	 * @author: Hqd
	 * @date: 2017年11月22日 上午10:31:02 
	 * @return
	 */
	@RequestMapping(value = "/consultant_import_client_to")
	public ModelAndView consultant_import_client_to(ModelMap modelMap,
			final BaseVo vo, final HttpServletRequest request,
			final HttpServletResponse response) throws Exception {
		modelMap = JsonExecutor.execute(logger, vo, new JsonBiz() {
			public Result process() {
				Result result = new ResultSupport(true);
				try {
					String keyname = request.getParameter("keyname");
					String lianxi_name = request.getParameter("lianxi_name");
					String age = request.getParameter("age");
					//String student_msg = request.getParameter("student_msg");
					String province = request.getParameter("province");
					String city = request.getParameter("city");
					String phone = request.getParameter("phone");
					String weixin = request.getParameter("weixin");
					String qq = request.getParameter("qq");
					String user = request.getParameter("user");
					//String descs = request.getParameter("descs");
					
					TgUser users = UserUtil.getUserFromCookies();
					SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
					
					if(user!=null && !"".equals(user)){
						//是否已超上限个数（客户资源）
						if(!"true".equals(checkSxian(user))){
							return result;
						}
					}else{
						return result;
					}
					
					if(keyname!=null && !"".equals(keyname)){
						JsVote clientImp = new JsVote();
						clientImp.setKeyname(keyname);
						List<JsVote> list = jsVoteDao.findByExample(clientImp);
						if(list!=null && list.size()>0){
							clientImp = list.get(0);
							if(clientImp!=null){
								//添加客户资料
								TgClient client = new TgClient();
								client.setType(3);
								client.setFrom_id(clientImp.getId());
								client.setKeyname(clientImp.getKeyname());
								client.setNickname(lianxi_name);
								client.setRawusername(clientImp.getUsername());
								client.setLodusername(user);
								client.setSource(clientImp.getType());
								client.setProvince(province);
								client.setCity(city);
								client.setPhone(phone);
								client.setWeixin(weixin);
								client.setQq(qq);
								client.setDescs("孩子情况："+clientImp.getStudent_msg()+"。其他:"+clientImp.getDescs());
								client.setCdate(new Date().getTime()/1000);
								clientDao.insert(client);
								//同时可以编辑信息
								clientImp.setLianxi_name(lianxi_name);
								/*clientImp.setCity(province+" "+city);
								clientImp.setPhone(phone);
								clientImp.setWeixin(weixin);
								clientImp.setQq(qq);
								clientImp.setDescs(descs);
								clientImp.setAge(age);*/
								clientImp.setTo_time(new Date());//设置分配时间
								clientImp.setTo_username(user);
								clientImp.setGo_username(users.getUsername());
								clientImp.setState("1");
								jsVoteDao.update(clientImp);
								
								//添加客户的孩子信息
								if((age!=null && !"".equals(age))){
									TgStudent student = new TgStudent();
									student.setKeyname(clientImp.getKeyname());
									student.setAge(age);
									studentDao.insert(student);
								}
								result.setDefaultModel("msg", "1");
							}
						}
					}
				} catch (ParseException e) {
					e.printStackTrace();
				}
				return result;
			}
		});
		return new ModelAndView("", modelMap);
	}

	public static void main(String[] args) {
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy/MM/dd HH:mm");

	    String st = "2017/7/25 星期二 下午 4:41:11";
	    String reg = "[\u4e00-\u9fa5]";
	  st = st.replaceAll(reg, "");
	  try {
	    System.out.println(sdf1.parse(st));
	} catch (ParseException e) {
	    e.printStackTrace();
	}
		WriterExcel.readExcel("D:/mydata/uploadoa/doc/离线宝导出.xls");
	}
}
